home *** CD-ROM | disk | FTP | other *** search
- class AtlantisBus extends MovingObject
- {
- var mcRef;
- var bKeyEasterPressed;
- var nKeyMoveUp;
- var nKeyMoveDown;
- var nKeyMoveLeft;
- var nKeyMoveRight;
- var nMovement;
- var nCurrentDir;
- static var sLINKAGE_NAME = "mcAtlantisBus";
- static var nMOVE_UP = Key.UP;
- static var nMOVE_DOWN = Key.DOWN;
- static var nMOVE_LEFT = Key.LEFT;
- static var nMOVE_RIGHT = Key.RIGHT;
- static var nNO_KEY = -99;
- static var nEASTER_EGG = 83;
- static var nSPEED = 1;
- static var nINITIAL_X = 10;
- static var nINITIAL_Y = 170;
- function AtlantisBus()
- {
- super(CTRLGame.getRef().mcRef.attachMovie(AtlantisBus.sLINKAGE_NAME,AtlantisBus.sLINKAGE_NAME,CTRLGame.getRef().calculateDepth(AtlantisBus.nINITIAL_Y,CTRLGame.nBUS_ADD)));
- this.mcRef._x = AtlantisBus.nINITIAL_X;
- this.mcRef._y = AtlantisBus.nINITIAL_Y;
- this.bKeyEasterPressed = false;
- if(!Main.getRef().EasterEgg)
- {
- this.nKeyMoveUp = AtlantisBus.nMOVE_UP;
- this.nKeyMoveDown = AtlantisBus.nMOVE_DOWN;
- this.nKeyMoveLeft = AtlantisBus.nMOVE_LEFT;
- this.nKeyMoveRight = AtlantisBus.nMOVE_RIGHT;
- }
- else
- {
- this.nKeyMoveUp = AtlantisBus.nMOVE_DOWN;
- this.nKeyMoveDown = AtlantisBus.nMOVE_UP;
- this.nKeyMoveLeft = AtlantisBus.nMOVE_RIGHT;
- this.nKeyMoveRight = AtlantisBus.nMOVE_LEFT;
- }
- }
- function cleanUp()
- {
- super.cleanUp();
- this.mcRef.swapDepths(7777);
- this.mcRef.removeMovieClip();
- }
- function doUnPause()
- {
- if(!CTRLGame.getRef().Screen.isInMiniGame())
- {
- super.doUnPause();
- }
- }
- function resumeAnim()
- {
- super.doUnPause();
- }
- function checkObjects()
- {
- CTRLGame.getRef().checkPowerUps();
- CTRLGame.getRef().checkAlgaes();
- CTRLGame.getRef().checkJellys();
- CTRLGame.getRef().checkDirtWalls();
- CTRLGame.getRef().checkFinish();
- }
- function manageMovement()
- {
- this.setupKeys();
- if(this.canMove() && this.nMovement == 0)
- {
- var _loc2_ = this.nCurrentDir;
- if(Key.isDown(this.nKeyMoveUp))
- {
- if(this.isNextMoveGood(CTRLGame.nDIR_UP))
- {
- this.setState(MovingObject.sSTATE_UP);
- this.nCurrentDir = CTRLGame.nDIR_UP;
- this.nMovement = MovingObject.nMAX_MOVEMENT;
- }
- }
- else if(Key.isDown(this.nKeyMoveDown))
- {
- if(this.isNextMoveGood(CTRLGame.nDIR_DOWN))
- {
- this.setState(MovingObject.sSTATE_DOWN);
- this.nCurrentDir = CTRLGame.nDIR_DOWN;
- this.nMovement = MovingObject.nMAX_MOVEMENT;
- }
- }
- else if(Key.isDown(this.nKeyMoveLeft))
- {
- if(this.isNextMoveGood(CTRLGame.nDIR_LEFT))
- {
- this.setState(MovingObject.sSTATE_LEFT);
- this.nCurrentDir = CTRLGame.nDIR_LEFT;
- this.nMovement = MovingObject.nMAX_MOVEMENT;
- }
- }
- else if(Key.isDown(this.nKeyMoveRight))
- {
- if(this.isNextMoveGood(CTRLGame.nDIR_RIGHT))
- {
- this.setState(MovingObject.sSTATE_RIGHT);
- this.nCurrentDir = CTRLGame.nDIR_RIGHT;
- this.nMovement = MovingObject.nMAX_MOVEMENT;
- }
- }
- if(this.nMovement == 0)
- {
- switch(this.nCurrentDir)
- {
- case CTRLGame.nDIR_UP:
- this.setState(MovingObject.sSTATE_IDLE_UP);
- break;
- case CTRLGame.nDIR_DOWN:
- this.setState(MovingObject.sSTATE_IDLE_DOWN);
- break;
- case CTRLGame.nDIR_LEFT:
- this.setState(MovingObject.sSTATE_IDLE_LEFT);
- break;
- case CTRLGame.nDIR_RIGHT:
- this.setState(MovingObject.sSTATE_IDLE_RIGHT);
- }
- }
- CTRLGame.getRef().Screen.manageAnim(this.nCurrentDir,_loc2_,this.nMovement);
- }
- }
- function setupKeys()
- {
- if(this.canMove())
- {
- if(!Key.isDown(AtlantisBus.nEASTER_EGG))
- {
- this.bKeyEasterPressed = false;
- }
- else if(Key.isDown(AtlantisBus.nEASTER_EGG) && (!Main.getRef().EasterEgg && !this.bKeyEasterPressed))
- {
- Main.getRef().setEasterEgg(true);
- this.bKeyEasterPressed = true;
- this.nKeyMoveUp = AtlantisBus.nMOVE_DOWN;
- this.nKeyMoveDown = AtlantisBus.nMOVE_UP;
- this.nKeyMoveLeft = AtlantisBus.nMOVE_RIGHT;
- this.nKeyMoveRight = AtlantisBus.nMOVE_LEFT;
- }
- else if(Key.isDown(AtlantisBus.nEASTER_EGG) && (Main.getRef().EasterEgg && !this.bKeyEasterPressed))
- {
- Main.getRef().setEasterEgg(false);
- this.bKeyEasterPressed = true;
- this.nKeyMoveUp = AtlantisBus.nMOVE_UP;
- this.nKeyMoveDown = AtlantisBus.nMOVE_DOWN;
- this.nKeyMoveLeft = AtlantisBus.nMOVE_LEFT;
- this.nKeyMoveRight = AtlantisBus.nMOVE_RIGHT;
- }
- }
- }
- function isNextMoveGood(_nNextDir)
- {
- var _loc3_ = this.getWishMidPos(_nNextDir);
- var _loc4_ = false;
- if(this.isTrackOkay(_nNextDir) && !CTRLGame.getRef().isTouchingWall(_loc3_.x,_loc3_.y))
- {
- _loc4_ = true;
- }
- return _loc4_;
- }
- function adaptDepth()
- {
- this.mcRef.swapDepths(CTRLGame.getRef().calculateDepth(this.mcRef._y,CTRLGame.nBUS_ADD));
- }
- function manageIdle()
- {
- this.manageMovement();
- CTRLGame.getRef().checkJellys();
- CTRLGame.getRef().checkAlgaes();
- }
- function IdleUp()
- {
- this.manageIdle();
- }
- function IdleDown()
- {
- this.manageIdle();
- }
- function IdleLeft()
- {
- this.manageIdle();
- }
- function IdleRight()
- {
- this.manageIdle();
- }
- function Left()
- {
- if(this.nMovement > 0 && this.canMove())
- {
- this.mcRef._x -= AtlantisBus.nSPEED;
- this.nMovement -= AtlantisBus.nSPEED;
- this.checkObjects();
- }
- this.manageMovement();
- }
- function Up()
- {
- if(this.nMovement > 0 && this.canMove())
- {
- this.mcRef._y -= AtlantisBus.nSPEED;
- this.nMovement -= AtlantisBus.nSPEED;
- this.adaptDepth();
- this.checkObjects();
- }
- this.manageMovement();
- }
- function Right()
- {
- if(this.nMovement > 0 && this.canMove())
- {
- this.mcRef._x += AtlantisBus.nSPEED;
- this.nMovement -= AtlantisBus.nSPEED;
- this.checkObjects();
- }
- this.manageMovement();
- }
- function Down()
- {
- if(this.nMovement > 0 && this.canMove())
- {
- this.mcRef._y += AtlantisBus.nSPEED;
- this.nMovement -= AtlantisBus.nSPEED;
- this.adaptDepth();
- this.checkObjects();
- }
- this.manageMovement();
- }
- }
-